package com.ht.right.dao.impl;

import java.util.List;

import com.ht.right.dao.RightDao;
import com.ht.right.entity.Right;
import com.ht.right.util.CommonUtil;

public class RightDaoImpl extends BaseDaoImpl<Right> implements RightDao {
	@Override
	public List<Right> getRightByOrgIds(String orgIds,String modoName){
		String hql = "from Right r where r.orgId in ("+ orgIds +")";
		if(CommonUtil.isNullOrEmpty(modoName)){
		}else{
			hql+=" and r.modoName = '"+modoName+"'";
		}
		return super.find(hql);
	}
	
	@Override
	public List<Right> getRightsByDocId(Right right) {
		// TODO Auto-generated method stub
		StringBuffer hql = new StringBuffer("from Right r where r.docId = '");
		hql.append(right.getDocId());
		hql.append("' ");
		if(CommonUtil.isNullOrEmpty(right.getModoName())){
		}else{
			hql.append(" and r.modoName = '");
			hql.append(right.getModoName());
			hql.append("'");
		}
		//String hql="from Right r where r.docId = '"+right.getDocId()+"' and r.modoName = '"+right.getModoName()+"'";
		return super.find(hql.toString());
	}
	@Override
	public List<Right> getRightsByDocId(String docId, String modoName) {
		StringBuffer hql = new StringBuffer("from Right r where r.docId = '");
		hql.append(docId);
		hql.append("' ");
		if(CommonUtil.isNullOrEmpty(modoName)){
		}else{
			hql.append(" and r.modoName = '");
			hql.append(modoName);
			hql.append("'");
		}
		//String hql="from Right r where r.docId = '"+right.getDocId()+"' and r.modoName = '"+right.getModoName()+"'";
		return super.find(hql.toString());
	}
}